files = Makefile src/charts.h src/counts.c src/helps.h src/list.h src/utils.h
pofiles = $(shell echo i18n/*.po)
outfile = counts
libs = -lm -lreadline -ltcl -ltk -lX11
defs = 

result = $(shell if test -d /usr/include/Tcl; then echo true; else echo false; fi)
ifeq ($(result), true)
	defs += -DTK_FRAMEWORK
endif

build: $(files)
	@gcc src/counts.c -o $(outfile) $(libs) $(defs) -s

install: $(files) $(pofiles)
	@python3 setup.py install

translate: $(files) $(pofiles)
	@xgettext src/*.c src/*.h --no-wrap --package-name="counts" \
		--package-version="1.0.0" -o i18n/counts.pot
	@$(foreach i, $(pofiles), msgmerge $i i18n/counts.pot -o $i;)

.PHONY: clean
clean:
	@-rm counts
